home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1997 May / PC Plus Super CD Issue 127 (May 1997).iso / delphi1 / lesson4 / todolist / closemsg.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-04-09  |  1.7 KB  |  63 lines

  1. unit Closemsg;
  2. {
  3.   PC Plus sample Delphi program.
  4.   Description:   A 'faked modal' dialog box which is displayed on screen
  5.                  for a defined period. Similar dialogs could be used as
  6.                  'splash screens' to be displayed while your program is loading.
  7.                  The present dialog is used by the International Clock
  8.                  application, intclock.dpr. It demonstrates the use of a Timer
  9.                  object to implement a delay. It has no real function
  10.                  apart from that.
  11.   Author:        Huw Collingbourne
  12. }
  13.  
  14. interface
  15.  
  16. uses
  17.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  18.   Forms, Dialogs, ExtCtrls, StdCtrls;
  19.  
  20. type
  21.   TCloseMsgForm = class(TForm)
  22.     Label1: TLabel;
  23.     Timer1: TTimer;
  24.     procedure Timer1Timer(Sender: TObject);
  25.     procedure FormShow(Sender: TObject);
  26.   private
  27.     { Private declarations }
  28.   public
  29.     { Public declarations }
  30.   end;
  31.  
  32. var
  33.   CloseMsgForm: TCloseMsgForm;
  34.   ATick : integer;
  35.  
  36. implementation
  37.  
  38. {$R *.DFM}
  39.  
  40. { This implements a modal form which lacks the usual OK, Cancel buttons.
  41.   Therefore the form must be closed by the code rather than the user
  42.   by returning ModalResult := mrOK }
  43.  
  44. procedure TCloseMsgForm.Timer1Timer(Sender: TObject);
  45. { Display form for a number of 'ticks' - i.e. timer events }
  46. const
  47.   TickCount = 20;
  48. begin
  49.   Label1.Caption := Label1.Caption + '.';
  50.   Inc(ATick);
  51.   if ATick = TickCount then ModalResult := mrOK;
  52. end;
  53.  
  54. procedure TCloseMsgForm.FormShow(Sender: TObject);
  55. { Init the timer and the ATick variable when this form is shown }
  56. begin
  57.   Timer1.Enabled := True;
  58.   Timer1.Interval := 100;
  59.   ATick := 0;
  60. end;
  61.  
  62. end.
  63.